package com.systop.service.UserServiceImpl;

import com.systop.mapper.UserMapper;
import com.systop.pojo.Identification;
import com.systop.pojo.School_data;
import com.systop.pojo.User;
import com.systop.service.UserService;
import com.systop.unti.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;

@Service
@Transactional

public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    //用户登陆
    public ResponseResult login(String user_name, String user_password) {
        User user = userMapper.login(user_name,user_password);
        return ResponseResult.ok(user);
    }
    //用户注册
    @Override
    public ResponseResult addUser(User user) {
        Integer i = userMapper.addUser(user);
        return ResponseResult.ok(i);
    }

    @Override
    public ResponseResult selUserByid(Integer user_id) {
        User user = userMapper.selUserByid(user_id);
        return ResponseResult.ok(user);
    }

    @Override
    public ResponseResult updUser(User user) {
        Integer i = userMapper.updUser(user);
        return ResponseResult.ok(i);
    }

    //用户认证（从学校数据里查找是否有这个人的信息）
    @Override
    public ResponseResult selUs(String school_data_name, String school_data_num, String school_data_college) {
        School_data school_data = userMapper.selUs(school_data_name, school_data_num, school_data_college);
        return ResponseResult.ok(school_data);
    }
    //用户认证（把信息填到认证表）
    @Override
    public ResponseResult addIdent(Identification identification) {
        Integer i  = userMapper.addIdent(identification);
        return ResponseResult.ok(i);
    }
    //查找数据库此用户名是否存在
    @Override
    public ResponseResult selUseName(String user_name) {
        User user = userMapper.selUseName(user_name);
        return ResponseResult.ok(user);
    }
}
